import request, { scope } from '../../utils/request';

const cartUrl = scope('user/cart');

/**
 * 购物车信息查询
 * @returns
 */
export const getCart = (userId, page, size) => {
  return request({
    url: cartUrl(`find/${page}/${size}`),
    method: 'post',
    data: {
      userId
    }
  });
};

export const updateCart = (userId, cartId, productId, productCount) => {
  return request({
    url: cartUrl('update'),
    method: 'post',
    data: {
      userId,
      cartId,
      productId,
      productCount
    }
  });
};


export const deleteCart = (userId, cartId, productId) => {
  return request({
    url: cartUrl('del'),
    method: 'post',
    data: {
      userId,
      cartId,
      productId
    }
  });
};

export const addCart = (userId, productId, count) => {
  return request({
    url: cartUrl('save'),
    method: 'post',
    data: {
      userId,
      productId,
      count
    }
  });
};
